def find_max_and_count():
    max_value = None
    count = 0
    
    while True:
        num = int(input())
        if num == 0:
            break
        
        if max_value is None or num > max_value:
            max_value = num
            count = 1
        elif num == max_value:
            count += 1
    
    if max_value is not None:
        print(max_value)
        print(count)

find_max_and_count()